
import numpy as np
from datas import datas
x=[]
y=[]
cityMark={"吕梁":1,"太原":2}
for item in datas:
    single=[]
    single.append(cityMark[item["city"]])

    single.append(item["area"])

    single.append(item["rooms"])

    single.append(item["school"])

    single.append(item["style"])



x.append(single)
y.append(item["price"])

x=np.array(x)
y=np.array(y)
print(x)
print(y)


theta=np.linalg.pinv(x.T.dot(x)).dot(x.T).dot(y)

print(theta.dot(np.array([2,100,2,1,1])))


#a=np.array([[1,2,3],[1,2,3]])
#b=np.array([1,2,3])
#print(a.dot(b))  #点乘


#print(a)
#print(a.T)   #转置矩阵


#print(np.linalg.pinv(a))   #矩阵求逆



